
/* .do file to append SSIandII with SSIII to create SSpooled.dta */

** prepare SS1and2 data for append
use "$dta/SS1and2.dta", clear


rename productionyears agyears
rename personid person_id
rename numofacresowned acresown
rename numofacresleased acreslease
rename rowcropacres acresrow
rename slidervariation default
rename realbid fracbid
rename isowner owner
decode state, generate(state_str)
replace person_id = person_id + 3000 //to avoid duplication with SS3 person_id numbers



//list of variables to keep
#delimit ;
keep fracbid bidindicator default gender age owner agyears  acresown acresrow acreslease totalacres noncrp person_id agvise itemnum crpindicator state_str inag1and2  ;
#delimit cr

rename crpindicator iscrp 

tempfile ss1and2
save "`ss1and2'", replace


**prepare SS3 data for append
use "$dta/SS3.dta", clear


gen itemnum = 9
gen agvise = 3     //indicator for SS3
decode state, generate(state_str)

//consistent yes-no codes for CRP variables
recode iscrp noncrp (1 = 0 "No") (2 = 1 "Yes"), prefix(new_) label(yesno_new)
gen inag1and2 = 0     //indicator for participants who were present in both SSI and SSII

#delimit ;
keep fracbid bidindicator default gender age owner agyears acresown acresrow acreslease totalacres new_noncrp person_id agvise itemnum state_str  new_iscrp inag1and2;
#delimit cr

rename new_* *

append using "`ss1and2'"

encode state_str,gen(state)
la var bidindicator " "

save "$dta/SSpooled.dta", replace 